package zhanyuduilie

func removeDuplicates(s string) string {
	b := []byte(s)
	if len(b) <= 1 {
		return s
	}
	stack := make([]byte, 0)
	stack = append(stack, b[0])
	for i := 1; i < len(b); i++ {
		if len(stack) > 0 && b[i] == stack[len(stack)-1] {
			stack = stack[:len(stack)-1]
		} else {
			stack = append(stack, b[i])
		}
	}
	return string(stack)
}
